package com.example.myapplication.baseMVVM;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModelProvider;

import com.jaeger.library.StatusBarUtil;

public abstract class BaseActivity<VDB extends ViewDataBinding,VM extends BaseViewModel> extends AppCompatActivity {
    protected  VDB binding;
    protected VM viewModel;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,bindLayout());
        viewModel = new ViewModelProvider(this).get(getViewModel());
        initView();
        initData();
        //沉浸式状态栏
        StatusBarUtil.setTranslucentForImageView(this,0,null);
    }

    protected abstract int bindLayout();
    protected abstract void initView();
    protected abstract void initData();
    protected abstract Class<VM> getViewModel();
}
